package com.project.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.SchoolBean;
import com.project.mapper.ISchoolMapper;
import com.project.service.ISchoolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Author(王思翰)
 * @Description(类的描述)
 * @Date(创建时间) 2021/7/13 18:12
 */
@Service
@Transactional
public class SchoolServiceImpl implements ISchoolService {
    @Autowired
    private ISchoolMapper mapper;

    @Override
    public PageInfo<SchoolBean> findByItem(int pageNO, String schoolName, String cityName, String status) {
        PageHelper.startPage(pageNO,3);
        PageInfo<SchoolBean> pageInfo=PageInfo.of(mapper.findByItem(schoolName,cityName,status));
        return pageInfo;
    }

    @Override
    public void addSchool(SchoolBean schoolBean) {
        mapper.addSchool(schoolBean);
    }

    @Override
    public SchoolBean findById(int id) {
        return mapper.findBySchoolId(id);
    }

    @Override
    public void updateSchool(int id, String status) {
        mapper.updateStatus(id,status);
    }

    @Override
    public void addIdeaByPass(int id, String idea, String status) {
        mapper.addIdea(id,idea);
        mapper.updateStatus(id,status);
    }

    @Override
    public void addIdeaByNoPass(int id, String idea, String status) {
        mapper.updateStatus(id,status);
        mapper.addIdea(id,status);
    }

    @Override
    public List<SchoolBean> findByCityId(int id) {
        return mapper.findByCityId(id);
    }
}
